package com.tanhua.server.redis.service;

import com.tanhua.model.db.UserInfo;
import org.junit.Test;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

@Service
public class UserInfoService {


   @Cacheable(value = "user")
    public UserInfo find(Long id){

       System.out.println("模拟从数据库中查询");
        UserInfo userInfo=new UserInfo();
        userInfo.setId(id);
        userInfo.setNickname("hanhan");
        return userInfo;
    }


    @CacheEvict(value = "user" ,key = "#id")
    public void update( Long id){
        UserInfo userInfo=new UserInfo();
        userInfo.setId(id);
        userInfo.setNickname("xinxin");
    }
}
